Block diagram algebraΒΆ
Example 3.1:
The textbook shows the solution as
\[z = ( P_{11} + P_{12} K ( I - P_{22} K )^{-1} P_{21} )w\]
We can do this calculation manually as follows:
\begin{align}
b &= a + P_{22} c \\
c &= K b \\
c &= K a + K P_{22} c \\
c - K P_{22} c &= K a \\
(I - K P_{22}) c &= K a \\
(I - K P_{22})^{-1} (I - K P_{22}) c &= (I - K P_{22})^{-1} K a\\
c &= (I - K P_{22})^{-1} K a\\
&= K (I - P_{22} K )^{-1} a~\text{(push-through)} \\
z &= f + e\\
&= P_{21}w + P_{12}c \\
&= (P_{21} + P_{12}\underbrace{K(I - P_{22}K)^{-1}P_{12}}_c) w
\end{align}
We should also be able to solve this problem symbolically using Sympy
In [1]:
import sympy
sympy.init_printing()
In [5]:
(w, a, b, c,
d, e, f, z,
P_21, P_22,
K, P_12, P_11) = sympy.symbols("""w, a, b, c,
d, e, f, z,
P_21, P_22,
K, P_12, P_11""", commutative=False
)
eqs = [a - P_21*w,
b - (a + d),
c - K*b,
d - P_22*c,
e - P_12*c,
f - P_11*w,
z - (e + f)]
Note this is the right call, unfortunately as of 2018-03-15, this causes an error.
In [7]:
# Uncomment to check if this solves now
# sympy.solve(eqs, (a, b, c, d, e, f, z))
If we are careful about the ordering, we can still get a sensible answer from SymPy without having to do tedious math ourselves.
In [8]:
# first we identify which variable can be eliminated by solving each equation
order = [a, b, c, d, e, f, z]
# This will store the solutions
solution = {}
for var, eq in zip(order, eqs):
# We solve each equation for the new unknown given all the other solutions
sol = sympy.solve(eq.subs(solution), var)[0]
# and add that solution to the list of knowns
solution[var] = sol
solution[z].collect(w)
Out[8]:
$$w \left(P_{11} + P_{12} K P_{21} + P_{12} K \left(1 - P_{22} K\right)^{-1} P_{22} K P_{21}\right)$$